**************************************************
**************************************************
**************************************************
**************************************************
**************************************************
**************************************************
**************************************************

****This do-file reproduces Figures 5 and 6 in the manuscript. 

*Rodon, Toni; Guinjoan, Marc. Beaten ballots: Political participation dynamics amidst police interventions, Political Science Research & Methods.

clear all
capture cd "INCLUDE YOUR PATH HERE" 

*log close
log using "log_figure5_6", text replace

*Variables are recoded executing the following command.
quiet do recodes_CEO863

***Figure 5: The effect of police intervention on turnout (individual-level analysis)
************************************************************************************

logit vote1o c.log_distance c.log_distance##c.log_distance ${controls}, cluster(PROV)
margins, at( log_distance=(0 (0.5) 4))
marginsplot,  ytitle("Predicted turnout", height(6)) title("") xtitle(, height(6)) legend(position(6)col(2) size(small)) ///
		scale(0.8) addplot(hist log_distance if e(sample) & log_distance<4.001 , width() yaxis(2) percent yscale(alt axis(2)) ///
		ytitle("", axis(2)) ylabel("", axis(2)) legend(off) color(%20))  graphregion(color(white) margin(l-2 b+5)) name(logdistance, replace)


logit vote1o c.log_distance##i.ins c.log_distance#c.log_distance c.log_distance#c.log_distance#i.ins ${controls_noins}, cluster(PROV)
margins, at( log_distance=(0 (0.5) 4) ins=(1 2 3 4) )
marginsplot,  ytitle("Predicted turnout", height(4)) xtitle(, height(6)) title("") legend(position(6)col(2) size(small)) scale(0.8) xsize(4) ysize(4) ///
			addplot(hist log_distance if e(sample) & log_distance<4.001 , width() yaxis(2) percent yscale(alt axis(2)) ytitle("", axis(2)) ///
			ylabel("", axis(2)) color(%20) legend(order(5 "Only and more Spanish than Catalan" 6 "Equally Catalan and Spanish" 7 "More Catalan than Spanish" 8 "Only Catalan"))) ///
			graphregion(color(white) margin(t-5 b-7))   name(logdistance_ins, replace)

graph combine logdistance logdistance_ins, col(1) graphregion(color(white)) xsize(4) ysize(4) name(Figure5, replace)

*TO EXPORT FIGURE, COMMENT OUT THE NEXT LINE
graph export "Figure_5.pdf", replace


***Figure 6: The effect of police interventions on whether R decided to vote the same referendum day or before)
***************************************************************************************************************

logit decisionvote i.distance_3 ${controls}, cluster(PROV) 
margins, at(distance_3=(0 1 2))
marginsplot, title("") xtitle(, height(6)) legend(pos(6) col(3)) xsize(3.5) ysize(3) graphregion(color(white)) ///
		ytitle(`"Probability to decide to vote"' `"during the referendum day"', height(8)) xtitle("Type of municipality", height(6))  name(decision_vote, replace)  ///
			addplot(hist distance_3 if e(sample) , bin(5) yaxis(2) percent yscale(alt axis(2)) ///
			ytitle("", axis(2)) ylabel("", axis(2)) legend(off) color(%20) xlabel(0 `""Affected" "municipality""' 1 `""Unaffected" "(Affected close)""' 2 `""Unaffected       " "(Affected far)        ""'))  ///
			graphregion(color(white))  scale(0.9) 

			
logit decisionvote ib4.ins ${controls_noins}, cluster(PROV)
margins, at(ins=(1 2 3 4))
marginsplot, title("") xtitle("Identity group", height(6))  ytitle(`"Probability to decide to vote"' `"during the referendum day"', height(8))  ///
	name(decisionvote_byins, replace)  addplot(hist ins if e(sample), bin(7) xlabel(1.2 `""Only and more" "Spanish""' 2.05 `""Dual" "identity""' 2.925 `""More" "Catalan""' 3.79 `""Only" "Catalan""', ///
	tstyle(major_notick))  yaxis(2) percent yscale(alt axis(2)) ytitle("", axis(2)) ylabel("", axis(2)) bcolor() color(%20) legend(off) graphregion(color(white)) ) scale(0.9)

	
logit decisionvote i.distance_3##i.ins3_noesp ${controls_noins}, cluster(PROV) 
margins, at(distance_3cat=(0 1 2) ins3_noesp=(1 2 3))
marginsplot, legend(pos(6) col(3)) xsize(3.5) ysize(3) title("") graphregion(color(white)) ///
	xlabel(0 `""Affected" "municipality""' 1 `""Unaffected" "(Affected close)""' 2 `""Unaffected       " "(Affected far)        ""') xtitle("Type of municipality", height(6)) ///
	ytitle(`"Probability to decide the vote"' `"during the referendum day"', height(8)) name(distanceXins, replace) addplot(hist distance_3 if e(sample) , bin(5) ///
	yaxis(2) percent yscale(alt axis(2)) ytitle("", axis(2)) ylabel("", axis(2)) legend(order(4 "Dual identity" 5 "More Catalan than Spanish" 6 "Only Catalan")) ///
	color(%20) xlabel(0 `""Affected" "municipality""' 1 `""Unaffected" "(Affected close)""' 2 `""Unaffected       " "(Affected far)        ""')) ///
	graphregion(color(white) margin(l+15 r+15 t-2 b-2)) scale(0.65) 


graph combine decision_vote decisionvote_byins, rows(1) graphregion(color(white)) name(combine1, replace)
graph combine combine1 distanceXins, rows(2) graphregion(color(white)) name(Figure6, replace)


*TO EXPORT FIGURE, COMMENT OUT THE NEXT LINE
graph export "Figure_6.pdf", replace
	
graph close
log close
